﻿using AutoMapper;
using Core.DTO.System.SysModule;
using Core.DTO.System.SysPerson;
using Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Common.AutoMapper
{
    public class MapperProfile: Profile
    {
        public MapperProfile()
        {
            CreateMap<SysModule, SysModulePostDTO>().ReverseMap();
            CreateMap<SysPerson, SysPersonListDTO>()
                .ForMember(d=>d.OrgName,s=>s.MapFrom(m=>m.Org.Name))
                .ForMember(d=>d.Roles,s=>s.MapFrom(m=>m.Roles.Select(r=>r.Name).ToArray()))
                .ReverseMap();
        }
    }
}
